package uk.co.douglashoskins.weathercompare;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

import com.nokia.mid.ui.gestures.GestureEvent;
import com.nokia.mid.ui.gestures.GestureInteractiveZone;
import com.nokia.mid.ui.gestures.GestureListener;

public class WeatherCanvas extends Canvas implements GestureListener {

	protected void keyPressed(int keyCode) {
		Screen s = ScreenStack.getInstance().getTopScreen();
		if (s != null) {
			s.keyPressed(keyCode, getGameAction(keyCode));
		}
	}
	
	protected void paint(Graphics g) {
		g.setColor(0xffffff);
		g.fillRect(0, 0, WeatherCompare.width, WeatherCompare.height);
		g.setColor(0);
		g.drawString("Loading..", 0, 0, Graphics.TOP | Graphics.LEFT);
		Screen s = ScreenStack.getInstance().getTopScreen();
		if (s != null) {
			s.paint(g);
		}
	}

	public void gestureAction(Object container, GestureInteractiveZone giz,
			GestureEvent ge) {
		Screen s = ScreenStack.getInstance().getTopScreen();
		if (s != null) {
			s.gestureOccurred(ge);
		}
	}

}
